/***************************************************
> Copyright (C) 2024 ==KINGYI== All rights reserved.
> File Name: nwk8.6.3.c
> Author:
> Mail: 
> Created Time: Tue 06 Aug 2024 05:07:48 AM PDT
***************************************************/

//创建进程，在子进程中把进程ID传递给父进程，父进程等待子进程结束，一分钟等不到时, 主动给子进程发信号SIGKILL，迫使它结束。

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/shm.h>
#include <sys/ipc.h>
#include <unistd.h>
#include <signal.h>
int main(int argc,const char* argv[])
{
       pid_t pid = 0; 
	key_t key = 0;
	int shmid = 0;
	int ret = 0;
	pid = fork();
	printf("pid = %d\n",pid);
	if(pid == 0)
	{
	 while(1)
	 {
	  printf("www\n");
           sleep(1);
	 
	 }
	}
	else if(pid > 0)
	{
		printf("pid = %d\n",pid);
	 sleep(60);
	 kill(pid,SIGKILL);
	}
	else
	{
	printf("fork reeorr\n");
	}
    return 0;
}
